from utility import *
from file_setting import *
from strategies.first_fit import first_fit
from strategies.worst_fit import worst_fit
from strategies.market_mechanism import market_mechanism
from strategies.vector_dot import vector_dot
from strategies.max_bru import max_bru
from strategies.max_dvol import max_dvol



if __name__ == "__main__":
    data_set_reader = DataSetReader()
    analyzer = ServerAnalyzer()

    server_capacity_tasks = data_set_reader.read_tasks(
        SERVER_CAPACITY_TASKS_DATA_SET_FILE_NAME)
    uniform_distribution_tasks = data_set_reader.read_tasks(
        UNIFORM_DISTRIBUTION_TASKS_DATA_SET_FILE_NAME)
    normal_distribution_tasks = data_set_reader.read_tasks(
        NORMAL_DISTRIBUTION_TASKS_DATA_SET_FILE_NAME)

    cpu_intensive_tasks = data_set_reader.read_tasks(
        CPU_INTENSIVE_TASKS_DATA_SET_FILE_NAME)
    io_intensive_tasks = data_set_reader.read_tasks(
        IO_INTENSIVE_TASKS_DATA_SET_FILE_NAME)
    network_intensive_tasks = data_set_reader.read_tasks(
        NETWORK_INTENSIVE_TASKS_DATA_SET_FILE_NAME)
    
    hybrid_workload_tasks = []
    hybrid_workload_tasks.extend(cpu_intensive_tasks)
    hybrid_workload_tasks.extend(io_intensive_tasks)
    hybrid_workload_tasks.extend(network_intensive_tasks)


    # placement strategies setting
    placement_stategies = [
        first_fit,
        worst_fit,
        vector_dot,
        market_mechanism,
        max_dvol,
        max_bru,
    ]


    # run data set analyzing for every strategy
    for strategy in placement_stategies:
        print strategy.__name__ + ":"
        # print analyzer.analyze_result(strategy(server_capacity_tasks))
        # print analyzer.analyze_result(strategy(uniform_distribution_tasks))
        print analyzer.analyze_result(strategy(normal_distribution_tasks))
        # print analyzer.analyze_result(strategy(hybrid_workload_tasks))